package com.yesido.spring.ioc.di;

import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import javax.annotation.Resource;

/**
 * @author yesido
 * @description
 * @date 2023-06-20 13:53
 * @Version 8.3
 */
@SpringBootApplication
public class MyTest implements CommandLineRunner {

    /**
     * 默认通过名称注入 如果找不到那么通过类型注入 如果有多个实现类 那么用name参数区分
     * 或者primary注解
     */
    @Resource(name="mysevice02")
    private Mysevice mysevice;

//    @Autowired
//    @Qualifier("mysevice02")
//    private Mysevice mysevice1;// 可以看到编译时就报错

    public static void main(String[] args) {
        SpringApplication.run(MyTest.class,args);
        String aaa = new String("aaa");
        System.out.println("aaa = " + aaa);
    }

    @Override
    public void run(String... args) throws Exception {
        int add = mysevice.add(1, 2);
        System.out.println(add);
    }
}
